package com.xxxx.controller;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * Created By ShaoXikai on 2022/7/16
 */

@Controller
@RequestMapping("/my")
public class MyController {

    private static final Log log = LogFactory.getLog(MyController.class);

    @RequestMapping("/testRequest")
    @ResponseBody
    public String testRequest(HttpServletRequest request) {
        // 接受页面传递的参数
        String uname = request.getParameter("uname");
        String upwd = request.getParameter("upwd");
        if ("admin".equals(uname) && "admin".equals(upwd)) {
            log.info("成功");
            return "ok";
        } else {
            log.info("失败");
            return "no";
        }
    }

    @RequestMapping("/testPathVal/{val}")
    public String testPathVal(@PathVariable String val, Model model) {
        model.addAttribute("msg", val);
        System.out.println(val);
        return "success";
    }

}
